/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
 * Copyright (C) 2019 XiaoMi, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#include "../../sdm660-pinctrl.dtsi"
#include "sdm660-overlay.dtsi"

&uartblsp1dm1 {
	status = "ok";
	pinctrl-names = "default";
	pinctrl-0 = <&uart_console_active>;
};

&ufsphy1 {
	vdda-phy-supply = <&pm660l_l1>;
	vdda-pll-supply = <&pm660_l10>;
	vdda-phy-max-microamp = <51400>;
	vdda-pll-max-microamp = <14200>;
	status = "ok";
};

&ufs1 {
	vdd-hba-supply = <&gdsc_ufs>;
	vdd-hba-fixed-regulator;
	vcc-supply = <&pm660l_l4>;
	vccq2-supply = <&pm660_l8>;
	vcc-max-microamp = <500000>;
	vccq2-max-microamp = <600000>;
	qcom,vddp-ref-clk-supply = <&pm660_l1>;
	qcom,vddp-ref-clk-max-microamp = <100>;

	status = "ok";
};

&pm660_gpios {
	/* GPIO 4 (NFC_CLK_REQ) */
	gpio@c300 {
		qcom,mode = <0>;
		qcom,vin-sel = <1>;
		qcom,src-sel = <0>;
		qcom,master-en = <1>;
		status = "okay";
	};

	/* GPIO 11 for Home Key */
	gpio@ca00 {
		status = "okay";
		qcom,mode = <0>;
		qcom,pull = <0>;
		qcom,vin-sel = <0>;
		qcom,src-sel = <0>;
		qcom,out-strength = <1>;
	};
};

&rpm_bus {
	disp_vddts_vreg: disp_vddts_vreg {
		compatible = "regulator-fixed";
		regulator-name = "disp_vddts_vreg";
		startup-delay-us = <4000>;
		enable-active-high;
		regulator-boot-on;
		gpio = <&tlmm 73 0>;
		};
	};

&spi_8 {
	status = "okay";
	irled@0 {
		compatible = "ir-spi";
		reg = <0x0>;
		status = "okay";
		spi-max-frequency = <1000000>;
	};
};

&mdss_mdp {
	qcom,mdss-pref-prim-intf = "dsi";
};

&mdss_dsi {
	hw-config = "single_dsi";
};

&mdss_dsi0 {
	pinctrl-names = "mdss_default", "mdss_sleep";
	pinctrl-0 = <&mdss_dsi_active &mdss_te_active>;
	pinctrl-1 = <&mdss_dsi_suspend &mdss_te_suspend>;
	qcom,platform-reset-gpio = <&tlmm 53 0>;
	qcom,platform-tp-reset-gpio = <&tlmm 66 0>;
	qcom,platform-te-gpio = <&tlmm 59 0>;
};

&mdss_dsi1 {
	status = "disabled";
};

&mdss_dsi1_pll {
	status = "disabled";
};

&mdss_dp_ctrl {
	status = "disabled";
	pinctrl-names = "mdss_dp_active", "mdss_dp_sleep";
	pinctrl-0 = <&mdss_dp_aux_active &mdss_dp_usbplug_cc_active>;
	pinctrl-1 = <&mdss_dp_aux_suspend &mdss_dp_usbplug_cc_suspend>;
	qcom,aux-en-gpio = <&tlmm 55 0>;
	qcom,aux-sel-gpio = <&tlmm 56 0>;
	qcom,usbplug-cc-gpio = <&tlmm 58 0>;
};

&pm660l_wled {
	qcom,en-cabc;
	qcom,fs-curr-ua = <20000>;
	qcom,led-strings-list = [00 01];
};

&dsi_dual_nt35597_truly_video {
	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
	qcom,mdss-dsi-bl-min-level = <1>;
	qcom,mdss-dsi-bl-max-level = <4095>;
	qcom,mdss-dsi-mode-sel-gpio-state = "dual_port";
	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
};

&dsi_dual_nt35597_truly_cmd {
	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
	qcom,mdss-dsi-bl-min-level = <1>;
	qcom,mdss-dsi-bl-max-level = <4095>;
	qcom,mdss-dsi-mode-sel-gpio-state = "dual_port";
	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
};

&dsi_dual_sharp_video {
	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
	qcom,mdss-dsi-bl-min-level = <1>;
	qcom,mdss-dsi-bl-max-level = <4095>;
	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
};

&dsi_nt35597_truly_dsc_video {
	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
	qcom,mdss-dsi-bl-min-level = <1>;
	qcom,mdss-dsi-bl-max-level = <4095>;
	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
};

&dsi_nt35597_truly_dsc_cmd {
	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
	qcom,mdss-dsi-bl-min-level = <1>;
	qcom,mdss-dsi-bl-max-level = <4095>;
	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
};

&dsi_nt35695b_truly_fhd_video {
	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
	qcom,mdss-dsi-bl-min-level = <1>;
	qcom,mdss-dsi-bl-max-level = <4095>;
	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
};

&dsi_nt35695b_truly_fhd_cmd {
	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
	qcom,mdss-dsi-bl-min-level = <1>;
	qcom,mdss-dsi-bl-max-level = <4095>;
	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
};

&dsi_rm67195_amoled_fhd_cmd {
	qcom,panel-supply-entries = <&dsi_panel_pwr_supply_labibb_amoled>;
};

&sdhc_1 {
	/* device core power supply */
	vdd-supply = <&pm660l_l4>;
	qcom,vdd-voltage-level = <2950000 2950000>;
	qcom,vdd-current-level = <200 570000>;

	/* device communication power supply */
	vdd-io-supply = <&pm660_l8>;
	qcom,vdd-io-always-on;
	qcom,vdd-io-lpm-sup;
	qcom,vdd-io-voltage-level = <1800000 1800000>;
	qcom,vdd-io-current-level = <200 325000>;

	pinctrl-names = "active", "sleep";
	pinctrl-0 = <&sdc1_clk_on &sdc1_cmd_on &sdc1_data_on &sdc1_rclk_on>;
	pinctrl-1 = <&sdc1_clk_off &sdc1_cmd_off &sdc1_data_off &sdc1_rclk_off>;

	qcom,clk-rates = <400000 20000000 25000000 50000000 100000000 192000000
								384000000>;

	qcom,nonremovable;
	qcom,bus-speed-mode = "HS400_1p8v", "HS200_1p8v", "DDR_1p8v";

	status = "ok";
};

&sdhc_2 {
	/* device core power supply */
	vdd-supply = <&pm660l_l5>;
	qcom,vdd-voltage-level = <2950000 2950000>;
	qcom,vdd-current-level = <15000 800000>;

	/* device communication power supply */
	vdd-io-supply = <&pm660l_l2>;
	qcom,vdd-io-voltage-level = <1800000 2950000>;
	qcom,vdd-io-current-level = <200 22000>;

	pinctrl-names = "active", "sleep";
	pinctrl-0 = <&sdc2_clk_on &sdc2_cmd_on &sdc2_data_on &sdc2_cd_on>;
	pinctrl-1 = <&sdc2_clk_off &sdc2_cmd_off &sdc2_data_off &sdc2_cd_off>;

	#address-cells = <0>;
	interrupt-parent = <&sdhc_2>;
	interrupts = <0 1 2>;
	#interrupt-cells = <1>;
	interrupt-map-mask = <0xffffffff>;
	interrupt-map = <0 &intc 0 0 125 0
			1 &intc 0 0 221 0
			2 &tlmm 54 0>;
	interrupt-names = "hc_irq", "pwr_irq", "status_irq";
	cd-gpios = <&tlmm 54 0x0>;

	qcom,clk-rates = <400000 20000000 25000000 50000000 100000000
								200000000>;
	qcom,bus-speed-mode = "SDR12", "SDR25", "SDR50", "DDR50", "SDR104";

	status = "ok";
};

&soc {
	qcom,msm-ssc-sensors {
		compatible = "qcom,msm-ssc-sensors";
	};
};

&mem_client_3_size {
	qcom,peripheral-size = <0xf00000>;
};

&pm660_charger {
	qcom,auto-recharge-soc;
};

&pm660_fg {
	qcom,fg-auto-recharge-soc;
};

&usb3 {
	dwc3@a800000 {
		maximum-speed = "high-speed";
	};
};

&usb3 {
	dwc3@a800000 {
		maximum-speed = "high-speed";
	};
};


&i2c_2 {
	status = "ok";
};

&pm660_vadc {
	chan@4d {
		label = "cam_therm0";
		reg = <0x4d>;
		qcom,decimation = <2>;
		qcom,pre-div-channel-scaling = <0>;
		qcom,calibration-type = "ratiometric";
		qcom,scale-function = <2>;
		qcom,hw-settle-time = <2>;
		qcom,fast-avg-setup = <0>;
	};

	chan@4e {
		label = "cam_therm1";
		reg = <0x4e>;
		qcom,decimation = <2>;
		qcom,pre-div-channel-scaling = <0>;
		qcom,calibration-type = "ratiometric";
		qcom,scale-function = <2>;
		qcom,hw-settle-time = <2>;
		qcom,fast-avg-setup = <0>;
	};

	chan@4f {
		label = "pa_therm0";
		reg = <0x4f>;
		qcom,decimation = <2>;
		qcom,pre-div-channel-scaling = <0>;
		qcom,calibration-type = "ratiometric";
		qcom,scale-function = <2>;
		qcom,hw-settle-time = <2>;
		qcom,fast-avg-setup = <0>;
	};

	chan@50 {
		label = "pa_therm1";
		reg = <0x50>;
		qcom,decimation = <2>;
		qcom,pre-div-channel-scaling = <0>;
		qcom,calibration-type = "ratiometric";
		qcom,scale-function = <2>;
		qcom,hw-settle-time = <2>;
		qcom,fast-avg-setup = <0>;
	};

	chan@54 {
		label = "backlight_therm";
		reg = <0x54>;
		qcom,decimation = <2>;
		qcom,pre-div-channel-scaling = <0>;
		qcom,calibration-type = "absolute";
		qcom,scale-function = <2>;
		qcom,hw-settle-time = <2>;
		qcom,fast-avg-setup = <0>;
	};
};

&pm660_adc_tm {
	chan@4d {
		label = "cam_therm0";
		reg = <0x4d>;
		qcom,pre-div-channel-scaling = <0>;
		qcom,calibration-type = "ratiometric";
		qcom,scale-function = <2>;
		qcom,hw-settle-time = <2>;
		qcom,btm-channel-number = <0x68>;
		qcom,thermal-node;
	};

	chan@4e {
		label = "cam_therm1";
		reg = <0x4e>;
		qcom,pre-div-channel-scaling = <0>;
		qcom,calibration-type = "ratiometric";
		qcom,scale-function = <2>;
		qcom,hw-settle-time = <2>;
		qcom,btm-channel-number = <0x80>;
		qcom,thermal-node;
	};

	chan@4f {
		label = "pa_therm0";
		reg = <0x4f>;
		qcom,pre-div-channel-scaling = <0>;
		qcom,calibration-type = "ratiometric";
		qcom,scale-function = <2>;
		qcom,hw-settle-time = <2>;
		qcom,btm-channel-number = <0x88>;
		qcom,thermal-node;
	};

	chan@50 {
		label = "pa_therm1";
		reg = <0x50>;
		qcom,pre-div-channel-scaling = <0>;
		qcom,calibration-type = "ratiometric";
		qcom,scale-function = <2>;
		qcom,hw-settle-time = <2>;
		qcom,btm-channel-number = <0x90>;
		qcom,thermal-node;
	};

	chan@54 {
		label = "backlight_therm";
		reg = <0x54>;
		qcom,pre-div-channel-scaling = <0>;
		qcom,calibration-type = "absolute";
		qcom,scale-function = <2>;
		qcom,hw-settle-time = <2>;
		qcom,btm-channel-number = <0x98>;
		qcom,thermal-node;
	};
};
